package com.ssps.back.platform.service.Impl;

import com.ssps.back.platform.service.InformationService;
import com.ssps.entity.*;
import com.ssps.mapper.InformationMapper;
import com.ssps.mapper.ParkingMapper;
import com.ssps.mapper.UserInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author li
 * @time 2020/07/23 19:13:13
 */

@Service
public class InformationServiceImpl implements InformationService {

    @Autowired
    InformationMapper informationMapper;
    @Autowired
    UserInfoMapper userInfoMapper;
    @Autowired
    ParkingMapper parkingMapper;

    @Override
    public List<Information> InformationFindAll(String status,String rplate) {
        InformationExample example=new InformationExample();
        InformationExample.Criteria criteria = example.createCriteria();
        if (status!=""&&status!=null){
            criteria.andStatusEqualTo(status);
        }
        if (rplate!=""&&status!=null){
            criteria.andRplateLike("%"+rplate+"%");
        }
        List<Information> informationList=informationMapper.selectByExample(example);
        if (informationList.size()>0){
            for (Information information : informationList) {
            UserInfo  userInfo=userInfoMapper.selectByPrimaryKey(information.getUiid());
            information.setUserInfo(userInfo);
            }
        }
        return informationList;
    }

    @Override
    public void InformationUpdate(Information information) {

        informationMapper.updateByPrimaryKeySelective(information);
    }
}
